package com.xmy.cultivate.listeners;

import com.xmy.cultivate.constants.MqConstants;
import com.xmy.cultivate.entity.GradeCustomSet;
import com.xmy.cultivate.service.IGradeCustomSetService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.ParseException;

@Slf4j
@Component
public class GradeCustomListener {

    @Autowired
    IGradeCustomSetService iGradeCustomSetService;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = MqConstants.QUEUE_CULTIVATE_GRADE_CUSTOM_ADD_Q1, durable = "true"),
            exchange = @Exchange(name = MqConstants.EXCHANGE_CULTIVATE_GRADE_CUSTOM_ADD_FANOUT, type = ExchangeTypes.FANOUT)
    ))
    public void gradeCustomCreate (Long id,Long createdId) throws ParseException {
        iGradeCustomSetService.gradeCustomCreate(id,createdId);
    }
}
